#include<stdio.h>
#include<unistd.h>
#include<time.h>
#include<stdlib.h>
#include"process.h"
#define total1 1024.0
#define speed 1.0
typedef void(*callback_t)(double ,double);
double rand1(double start,double end)
{
	int int_end = (int)end;
	return start+rand()%int_end+(end-start);
}
void Download(double total,callback_t cb)
{
	srand((unsigned int)time(NULL));
	double cur = 0;
	while(1)
	{
		if(cur>=total)
		{
			cb(cur,total);
			break;
		}
		cb(cur,total);
		cur+= (speed,20.50);
		usleep(30000);
	}
		printf("\n");
}
int main()
{

	//process1();
	 printf("download: 20.0MB\n");
    Download(20.0, process2);
    printf("download: 2000.0MB\n");
    Download(2000.0, process2);
    printf("download: 100.0MB\n");
    Download(100.0, process2);
    printf("download: 20000.0MB\n");
    Download(20000.0, process2);
	Download(10000,process2);
	return 0;
}
